package com.ihr360.sharedservice.common.controller;

import com.ihr360.sharedservice.common.dao.DataCacheDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by Eric on 2018/4/10/010.
 */
@RestController
@RequestMapping(value = "/common/cache")
public class DataCacheController {
    @Autowired
    private DataCacheDao dataCacheDao;

    @GetMapping(value = "/put",name = "redis保存")
    public void put(@RequestParam String key, @RequestParam String value){
        dataCacheDao.put(key,value);
    }

    @GetMapping(value = "/remove",name = "redis删除")
    public void remove(@RequestParam String key){
        dataCacheDao.remove(key);
    }

    @GetMapping(value = "/removeAll",name = "redis删除所有")
    public void removeAll(@RequestParam Set<String> keys){
        dataCacheDao.removeAll(keys);
    }

    @GetMapping(value = "/putAll",name = "redis保存所有")
    public void putAll(@RequestParam Map<? extends String, ? extends String> map){
        dataCacheDao.putAll(map);
    }

    @GetMapping(value = "/getAll",name = "redis获取所有")
    public List<String> getAll(@RequestParam List<String> keys){
        return dataCacheDao.getAll(keys);
    }

    @GetMapping(value = "/get",name = "redis获取")
    public String get(@RequestParam String key){
        return dataCacheDao.get(key);
    }
}
